home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
simula
/
books
/
books.lha
/
kirkerud
/
histo1.sim
< prev
next >
Wrap
Text File
|
1993-08-16
|
1KB
|
41 lines
! The program constructed in the first part of
! chapter 4 (section 4.7, fig. 4.3);
begin
integer array count(5 : 200);
integer weight_group, least_weight_group, greatest_weight_group,
asterisk_number, number_of_asterisks;
real weight;
! Read the measurements one by one: ;
outtext(" Please type the weights. "); outimage;
outtext(" Remember to type -1 after the last one!"); outimage;
weight := inreal;
while weight ge 0 do
begin
weight_group := entier(weight);
count(weight_group) := count(weight_group) + 1;
weight := inreal;
end;
! Find the least and greatest weight_groups containing weights: ;
least_weight_group := 5;
while count(least_weight_group) = 0
do least_weight_group := least_weight_group + 1;
greatest_weight_group := 200;
while count(greatest_weight_group) = 0
do greatest_weight_group := greatest_weight_group - 1;
! Write the histogram: ;
outtext("Weight : Number of children"); outimage;
for weight_group := least_weight_group step 1 until greatest_weight_group do
begin
outint(weight_group, 6); outtext(" : ");
number_of_asterisks := count(weight_group);
for asterisk_number := 1 step 1 until number_of_asterisks do outchar('*');
outimage;
end of weight_group-repetition;
end;